﻿using System;
using System.IO;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Navigation;
using WpfHero;

namespace Tutorial
{
	public partial class SongScroller
	{
		public SongScroller()
		{
			this.InitializeComponent();

            DataContextChanged += delegate { _engine = ((WHEngine)DataContext); };
		}

        WHEngine _engine;

        public void Start()
        {
            App.DoEvents();

            DoubleAnimation da = new DoubleAnimation()
            {
                From = 0,
                To = (grid.ActualWidth * -1) + stackPanel.Margin.Left,
                Duration = new Duration(_engine.EndOfSong)
            };
            stackPanel.RenderTransform = new TranslateTransform();
            stackPanel.RenderTransform.BeginAnimation(TranslateTransform.XProperty, da);
        }

	}
}